package com.lyh.educationtrain.entity.response;

public class Response {

	private int status = 0;

	private Error error = null;

	
	private Object result = null;

	public Response() {
	}

	public Response(int status, Error error, Object result) {
		this.status = status;
		this.error = error;
		this.result = result;
	}
	public Response(int status, Integer errorCode,String errorMsg) {
		this.status = status;
		Error error = new Error(errorCode, errorMsg);
		this.error = error;
	}

	public static Response success(Object result) {
		return new Response(0, null, result);
	}

	public static Response fail(int code, String message) {
		Response res = new Response();
		res.setStatus(1);
		Error error = res.new Error(code, message);
		res.setError(error);
		return res;
	}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	public Error getError() {
		return error;
	}

	public void setError(Error error) {
		this.error = error;
	}

	public Object getResult() {
		return result;
	}

	public void setResult(Object result) {
		this.result = result;
	}


	class Error {
		private String message = "";
		
		private int code = 0;

		public Error(int code, String message) {
			this.code = code;
			this.message = message;
		}

		public String getMessage() {
			return message;
		}

		public void setMessage(String message) {
			this.message = message;
		}

		public int getCode() {
			return code;
		}

		public void setCode(int code) {
			this.code = code;
		}


	}

}
